package com.example.arithmeticleetcode.leetcode;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-05-18 14:41
 **/
public class Demo20 {

    public static void main(String[] args) {
        int[] startTime = {1, 2, 3}, endTime = {3, 2, 7};
        int[] startTime1 = {4}, endTime1 = {4};
        int[] startTime2 = {1, 1, 1, 1}, endTime2 = {1, 3, 2, 4};
        int[] startTime3 = {9, 8, 7, 6, 5, 4, 3, 2, 1}, endTime3 = {10, 10, 10, 10, 10, 10, 10, 10, 10};
        System.out.println(busyStudent(startTime, endTime, 4));
        System.out.println(busyStudent(startTime1, endTime1, 4));
        System.out.println(busyStudent(startTime1, endTime1, 5));
        System.out.println(busyStudent(startTime2, endTime2, 7));
        System.out.println(busyStudent(startTime3, endTime3, 5));
    }

    public static int busyStudent(int[] startTime, int[] endTime, int queryTime) {
        int count = 0;

        for (int i = 0, len = startTime.length; i < len; i++) {
            if (startTime[i] <= queryTime && queryTime <= endTime[i]) {
                count++;
            }
        }

        return count;
    }
}
